package squarePackage;


import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class TeleportTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		square = new PlainSquare();
		List <SquareImp> list = new ArrayList <SquareImp>();
		list.add(square);
		plainSquare = new TeleportPlainSquare(list);
		transparantSquare =  new TeleportTransparantSquare(list);
	}

	@After
	public void tearDown() throws Exception {
	}
	
	TeleportPlainSquare plainSquare;
	TeleportTransparantSquare transparantSquare;
	SquareImp square;
	SquareImp rockSquare;

	
	@Test
	public final void isValidDestinationSquare(){
		assertTrue(transparantSquare.isValidDestination(square));
	}
	
	@Test
	public final void isValidDestinationNull(){
		assertFalse(transparantSquare.isValidDestination(null));
	}
	
	@Test
	public final void isValidDestinationRock(){
		assertFalse(transparantSquare.isValidDestination(rockSquare));
	}
	
	@Test
	public final void setRockDestination(){
		plainSquare.setDestination(rockSquare);
		assertEquals(1, plainSquare.getDestinationList().size());
	}
	
	@Test
	public final void setDestination(){
		SquareImp newSquare = new PlainSquare();
		plainSquare.setDestination(newSquare);
		assertEquals(2, plainSquare.getDestinationList().size());
	}
	
	@Test
	//List voegt dubbel uit zichzelf niet toe
	public final void setDubbelDestination(){
		plainSquare.setDestination(square);
		assertEquals(1, plainSquare.getDestinationList().size());
	}
	
	@Test
	public final void isValidDestinationList(){
		List <SquareImp> list = new ArrayList <SquareImp>();
		list.add(square);
		list.add(rockSquare);
		assertFalse(plainSquare.isValidDestinationList(list));
	}
	
	@Test
	public final void setThisDestination(){
		plainSquare.setDestination(plainSquare);
		assertFalse(plainSquare.isValidDestination(plainSquare));
		assertEquals(1,plainSquare.getDestinationList().size());
	}
	
	@Test
	public final void setDubbleDestination(){
		plainSquare.setDestination(square);
		assertEquals(1,plainSquare.getDestinationList().size());
	}
	
	@Test
	public final void chooseRandomTestWithOneDestination(){
		assertEquals(square, plainSquare.chooseRandomDestination());
	}
	
	@Test
	public final void chooseRandomTestWithMoreDestination(){
		SquareImp newSquare1 =  new PlainSquare();
		SquareImp newSquare2 =  new PlainSquare();
		SquareImp newSquare3 =  new PlainSquare();
		plainSquare.setDestination(transparantSquare);
		plainSquare.setDestination(newSquare1);
		plainSquare.setDestination(newSquare2);
		plainSquare.setDestination(newSquare3);
		System.out.println(plainSquare.getDestinationList());
		System.out.println(plainSquare.chooseRandomDestination());
	}
	
}
